import Vue from 'vue'
import Router from 'vue-router'
import CommonData from '@/utils/commonData'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
// 数智中心
  {
    path: '/',
    component: Layout,
    redirect: '/workBench',
    children: [{
      path: '/workBench',
      name: 'workBench',
      component: () => import('@/views/workBench/index.vue')
    }]
  },
  { //企业管理
    path: '/userAdmin',
    component: Layout,
    redirect: '/userAdmin/staffManagement',
    children: [
      {
        path: '/userAdmin/staffManagement', //人员管理
        name: 'staffManagement',
        component: () => import('@/views/userAdmin/staffManagement/index.vue'),
      },
      {
        path: '/userAdmin/roleManagement',  //角色管理
        name: 'roleManagement',
        component: () => import('@/views/userAdmin/roleManagement/index.vue'),
      },
    ]
  },
// 标的发布
  {
    path: '/sellerRelease',
    component: Layout,
    children: [
      {
        path: '/sellerRelease',
        name: 'sellerRelease',
        component: () => import('@/views/sellerRelease/index.vue'),
      }
    ]
  },
  {
    path: '/lotsReleaseAdd',
    component: Layout,
    children: [
      {
        path: '/lotsReleaseAdd',
        name: 'lotsReleaseAdd',
        component: () => import('@/views/lotsReleaseAdd/index.vue'),
      }
    ]
  },
  {
    path: '/lotsReleaseDetail',
    component: Layout,
    children: [
      {
        path: '/lotsReleaseDetail',
        name: 'lotsReleaseDetail',
        component: () => import('@/views/lotsReleaseDetail/index.vue'),
      }
    ]
  },
  // 交易管理
  {
    path: '/sellerTransaction',
    component: Layout,
    redirect: '/sellerTransaction',
    children: [
      {
        path: '/sellerTransaction',
        name: 'sellerTransaction',
        component: () => import('@/views/sellerTransaction/index.vue'),
      }
    ]
  },
  // 客户管理
  {
    path: '/custom',
    component: Layout,
    redirect: '/custom/serviceAccess',
    children: [  
      {  //评价记录
        path: '/custom/evaluationRecord',
        name: 'evaluationRecord',
        component: () => import('@/views/custom/evaluationRecord/index.vue')
      },
      { //买家管理
        path: '/custom/buyerManagement',
        name: 'buyerManagement',
        component: () => import('@/views/custom/buyerManagement/index.vue')
      }
    ]
  },
  // 信息管理
  {
    path: '/information',
    component: Layout,
    redirect: '/information/dataStatistics',
    children: [  
      {   //数据统计
        path: '/information/dataStatistics',
        name: 'dataStatistics',
        component: () => import('@/views/information/dataStatistics/index.vue')
      },
      {  //资料下载
        path: '/information/dataDownload',
        name: 'dataDownload',
        component: () => import('@/views/information/dataDownload/index.vue')
      },
      { //钢架信息
        path: '/information/steelPriceInfo',
        name: 'steelPriceInfo',
        component: () => import('@/views/information/steelPriceInfo/index.vue')
      },
      { //资料下载详情
        path: '/information/DownStatistic',
        name: 'DownStatistic',
        component: () => import('@/views/information/DownStatistic/index.vue')
      },
    ]
  },
  // 站内消息
  {
    path: '/commonProblem',
    component: Layout,
    children: [
      {
        path: '/commonProblem',
        name: 'commonProblem',
        component: () => import('@/views/commonProblem/index.vue'),
      }
    ]
  },

  

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  },

  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/404', hidden: true }
]




const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
})

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
  const newRouter = createRouter()
  router.matcher = newRouter.matcher // reset router
}

export default router
